Skip to content

Fix outdated GenAI APIs and add Windows ML guidance#249

Open
nmetulev wants to merge 1 commit intoMicrosoftDocs:docsfrom
nmetulev:fix/update-genai-walkthrough-apis
Open

Fix outdated GenAI APIs and add Windows ML guidance#249
nmetulev wants to merge 1 commit intoMicrosoftDocs:docsfrom
nmetulev:fix/update-genai-walkthrough-apis

Conversation

@nmetulev
Copy link
Copy Markdown
Contributor

@nmetulev nmetulev commented Apr 10, 2026

Summary

This PR fixes broken code in the GenAI walkthrough and updates both model walkthroughs to use Windows ML APIs instead of standalone ONNX Runtime packages.

Changes

docs/models/get-started-models-genai.md

  • Fix compile errors: The InferStreaming code sample uses SetInputSequences and ComputeLogits which were removed from ONNX Runtime GenAI in v0.6.0 (continuous decoding change). Updated to:
    • generatorParams.SetInputSequences(sequences)generator.AppendTokenSequences(sequences)
    • Removed generator.ComputeLogits() (now handled internally by GenerateNextToken())
  • Switch to .WinML package: Changed from Microsoft.ML.OnnxRuntimeGenAI.DirectML to .WinML for automatic hardware EP selection
  • Add alternative packages section: Documents DirectML, QNN, and CPU-only packages for specific EP targeting

docs/models/get-started-onnx-winui.md

  • Switch to Windows ML: Replaced standalone Microsoft.ML.OnnxRuntime.DirectML + SharpDX.DXGI with Microsoft.WindowsAppSDK.ML
  • Use EP Catalog: Replaced manual AppendExecutionProvider_DML + SharpDX adapter selection with ExecutionProviderCatalog.EnsureAndRegisterCertifiedAsync()
  • Remove SharpDX dependency: No longer needed — Windows ML handles hardware selection

Why

The docs/models/ walkthroughs are high-traffic entry points (they rank well in search for "WinUI ONNX model" queries). Currently they send developers to the standalone ONNX Runtime path, bypassing Windows ML's shared runtime and automatic EP management. These changes align the walkthroughs with the recommended Windows ML path documented in docs/new-windows-ml/.

How this was validated

Built a WinUI 3 test app exercising both paths:

  • GenAI: Phi-4-mini-instruct (LLM) — generated correct text output with .WinML 0.13.1
  • Traditional ML: SqueezeNet 1.1 (classification) — 1000-class inference output via EP Catalog + InferenceSession
  • EP Catalog correctly returns null on VMs (no GPU) and falls back to CPU

@nmetulev nmetulev force-pushed the fix/update-genai-walkthrough-apis branch from a3347ad to b834953 Compare April 10, 2026 05:50
- Update InferStreaming in get-started-models-genai.md to use current
  OnnxRuntimeGenAI 0.6+ APIs:
  - SetInputSequences -> generator.AppendTokenSequences (moved to Generator)
  - Remove ComputeLogits (handled by GenerateNextToken internally)
  These APIs were removed in the continuous decoding change:
  microsoft/onnxruntime-genai#1142

- Switch GenAI walkthrough from .DirectML to .WinML package for
  automatic hardware EP selection. Add alternative packages section.

- Switch ONNX WinUI walkthrough from standalone ORT + SharpDX.DXGI
  to Windows ML (Microsoft.WindowsAppSDK.ML):
  - Replace manual DirectML adapter selection with EP Catalog
  - Remove SharpDX.DXGI dependency
  - Use async InitModelAsync with EnsureAndRegisterCertifiedAsync

Co-authored-by: Copilot <[email protected]>
@nmetulev nmetulev force-pushed the fix/update-genai-walkthrough-apis branch from b834953 to 0dddb04 Compare April 10, 2026 05:58
@nmetulev nmetulev marked this pull request as ready for review April 10, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant